package com.todo.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableId;
import com.todo.dao.TeamInfoDAO;
import com.todo.dto.TeamMemberDTO;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class TeamInfo implements Serializable {

    @TableId(value = "tid")
    private String tid;

    /**
     * 所有者uid
     */
    private String tOwner;

    /**
     *成员列表
     */
    private List<TeamMemberDTO> tMemberList;

    /**
     * 成员数量
     */
    private int tMemberCount;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    public TeamInfoDAO toTeamInfoDAO(){
        TeamInfoDAO teamInfoDAO = new TeamInfoDAO();
        teamInfoDAO.setTid(this.tid);
        teamInfoDAO.setTOwner(this.tOwner);
        teamInfoDAO.setCreateTime(this.createTime);
        teamInfoDAO.setUpdateTime(this.updateTime);
        //将list对象转为json字符串
        String jsonString = JSON.toJSONString(this.tMemberList);
        teamInfoDAO.setTMemberList(jsonString);
        return teamInfoDAO;
    }

}
